package com.gywj.race.controller.api;

import com.gywj.race.config.result.AjaxResultHandler;
import com.gywj.race.dto.GetPatchNumberBookDataDto;
import com.gywj.race.service.DownloadAllNumberBookService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
public class DownloadAllNumberBookController {

    @Resource
    private DownloadAllNumberBookService downloadAllNumberBookService;
    @PostMapping("/download/allNumberBook/by/eventId/online/status")
    public Map<String,Object> downloadAllNumberBookByEventId(
            @RequestBody GetPatchNumberBookDataDto getPatchNumberBookDataDto,
            HttpServletResponse response){
        try {
            downloadAllNumberBookService.downloadAllNumberBookByEventId(getPatchNumberBookDataDto,response);
            return AjaxResultHandler.Success();
        }catch (Exception e){
            return AjaxResultHandler.Failed(e.getMessage());
        }
    }

    @GetMapping("download/NumberBook/NoName/Bm")
    public Map<String,Object> downloadNumberBookNoNameBm( HttpServletResponse response){
        try {
            downloadAllNumberBookService.downloadNumberBookNoNameBm(response);
            return AjaxResultHandler.Success();
        }catch (Exception e){
            return AjaxResultHandler.Failed(e.getMessage());
        }
    }

    @GetMapping("download/NumberBook/NoName/Qm")
    public Map<String,Object> downloadNumberBookNoNameQm( HttpServletResponse response){
        try {
            downloadAllNumberBookService.downloadNumberBookNoNameQm(response);
            return AjaxResultHandler.Success();
        }catch (Exception e){
            return AjaxResultHandler.Failed(e.getMessage());
        }
    }
}
